<?php
namespace app\admin\logic;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;
class ShangpinLogic
{
    public static function getWhere()
    {

        $keywords = Request::param('keywords','');
        $recommended = Request::param('recommended','');
        $if_show = Request::param('if_show',[]);
        $is_photo = Request::param('is_photo','');
        $where = [];
        $whereOr = [];

        if (!empty($keywords)) $where[] = ['brand_name','like',"%{$keywords}%"];
        if (isset($recommended) && $recommended !='')$where[] = ['recommended','=',$recommended];
        if(isset($if_show) && !empty($if_show)) $where[] = ['if_show','in',$if_show];
        if(!empty($is_photo) && count($is_photo) == 1){
            if (in_array(0,$is_photo)){
                $whereOr[] = ['brand_logo','=',''];
                $whereOr[] = ['brand_logo','=',null];
            }

            if (in_array(1,$is_photo)){
                $where[] = ['brand_logo','<>',''];
            }


        }
        View::assign('recommended',$recommended);


        return  [$where,$whereOr];
    }



}